package com.cctc.framework.controller;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cctc.framework.domain.Tree;
import com.cctc.framework.services.TreeService;

@Controller
@RequestMapping("/tree")
public class TreeController
{
    private static final Log log=LogFactory.getLog(TreeController.class);
    @Autowired
    private TreeService treeService;
    
    @ResponseBody
    @RequestMapping(value = "/{treeName}/index.json")
    public List<Tree> getTreeObject(@PathVariable("treeName") String treeName)
    {
        return treeService.getTreeObject(treeName);
    }
    
    @ResponseBody
    @RequestMapping(value = "/{parentId}/child.json")
    public List<Tree> getTreeObject(@PathVariable("parentId") int parentId)
    {
        return treeService.getTreeObject(parentId);
    }
}
